import React from 'react';
import Ex from 'ex';
import Ux from 'ux';
import Jsx from './Web';
import './Cab.less';

const componentInit = (reference) => {
    const {$inited = {}} = reference.props;
    let state = {};
    // GET /api/authority/region/:type
    // GET /api/authority/region-v/:owner
    Ex.aclRegion($inited, state).then(processed => {
        processed.$ready = true;
        const {$regions = []} = processed;
        processed.$activeKey = $regions[0].key;
        reference.setState(processed);
    })
}

@Ux.zero(Ux.rxEtat(require("./Cab"))
    .cab("ExAuthority")
    .to()
)
class Component extends React.PureComponent {
    componentDidMount() {
        componentInit(this);
    }

    render() {
        return Ex.yoRender(this, () => {
            return (
                <div className={"ex-authority"}>
                    {Jsx.renderHeader(this)}
                    {/** Dynamic Regions: $regions **/}
                    {Jsx.renderPage(this)}
                </div>
            )
        }, Ex.parserOfColor("ExAuthority").component());
    }
}

export default Component